package com.ruoyi.web.controller.comprehensive;

import com.github.pagehelper.PageInfo;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.comprehensive.domain.FirePreventionExamine;
import com.ruoyi.comprehensive.dto.FirePreventionExamineDto;
import com.ruoyi.comprehensive.service.IFirePreventionExamineService;
import com.ruoyi.comprehensive.vo.FireVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 防火审核Controller
 * 
 * @author hcc
 * @date 2023-12-16
 */
@RestController
@RequestMapping("/comprehensive/fireExamine")
public class FirePreventionExamineController extends BaseController
{
    @Autowired
    private IFirePreventionExamineService firePreventionExamineService;

    /**
     * 查询防火审核列表
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:fireExamine:list')")
    @GetMapping("/list")
    public TableDataInfo list(FirePreventionExamine firePreventionExamine)
    {
        startPage();
        List<FirePreventionExamine> list = firePreventionExamineService.selectFirePreventionExamineList(firePreventionExamine);
        return getDataTable(list);
    }

    /**
     * 导出防火审核列表
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:fireExamine:export')")
    @Log(title = "防火审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FirePreventionExamine firePreventionExamine)
    {
        List<FirePreventionExamine> list = firePreventionExamineService.selectFirePreventionExamineList(firePreventionExamine);
        ExcelUtil<FirePreventionExamine> util = new ExcelUtil<FirePreventionExamine>(FirePreventionExamine.class);
        util.exportExcel(response, list, "防火审核数据");
    }

    /**
     * 获取防火审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:fireExamine:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(firePreventionExamineService.selectFirePreventionExamineById(id));
    }

    /**
     * 新增防火审核
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:fireExamine:add')")
    @Log(title = "防火审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FirePreventionExamine firePreventionExamine)
    {
        return toAjax(firePreventionExamineService.insertFirePreventionExamine(firePreventionExamine));
    }

    /**
     * 修改防火审核
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:fireExamine:edit')")
    @Log(title = "防火审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FirePreventionExamine firePreventionExamine)
    {
        return toAjax(firePreventionExamineService.updateFirePreventionExamine(firePreventionExamine));
    }

    /**
     * 删除防火审核
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:fireExamine:remove')")
    @Log(title = "防火审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(firePreventionExamineService.deleteFirePreventionExamineByIds(ids));
    }
    /**
     * 查询防火审核列表
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:fireExamine:list')")
    @GetMapping("/getList")
    public TableDataInfo getList(FireVo vo) {
        startPage();
        PageInfo<FirePreventionExamineDto> list = firePreventionExamineService.getFirePreventionExamineList(vo);
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(HttpStatus.SUCCESS);
        rspData.setMsg("查询成功");
        rspData.setRows(list.getList());
        rspData.setTotal(list.getTotal());
        return rspData;
    }
}
